﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace wpf.Triage
{
    /// <summary>
    /// 隐藏MutiConvert
    /// </summary>
    public class VisibilityConvert : IValueConverter
    {
        /// <summary>
        /// 指定参数匹配字符串转显隐方法  2022-03-28
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {//parameter 需要给true 或false
            Visibility visbility = Visibility.Collapsed;
            try
            {
                string Oper = "TRUE";
                if (parameter != null && !parameter.ToString().Equals(string.Empty))
                {
                    Oper = parameter.ToString().ToUpper().Trim();
                }
                //只要包含，就显示
                if (value != null && value.ToString().ToUpper().Contains(Oper))
                {
                    visbility = Visibility.Visible;
                }
                else
                {
                    visbility = Visibility.Collapsed;
                }
            }
            catch
            {
            }
            return visbility;
        }
        /// <summary>
        /// 接口实现   2022-03-28
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return string.Empty;
        }
    }
}
